FOR entry% = 1 TO numentry% 'get rid of any ascii 0's
tempstring$ = ""
FOR leng% = 1 TO LEN(item$(entry%))
defaultstr$ = MID$(item$(entry%), leng%, 1)
IF ASC(defaultstr$) = 0 THEN defaultstr$ = " "
tempstring$ = tempstring$ + defaultstr$
NEXT leng%
item$(entry%) = RTRIM$(tempstring$)
NEXT entry%
LOCATE , , 0 'turn off cursor
COLOR sfg%, sbg%
END SUB
FUNCTION Justify$ (text$, just%, winleft%, winright%)
REM function to justify text on a line within a window
REM text$ is the string to be modified
REM just% = one of the following
REM 0 = not justiied
REM 1 = left justified
REM 2 = centre justified
REM 3 = right justified
REM winleft% = the leftmost column of the window
REM winright% = the rightmost column of the window
SELECT CASE just%
CASE 0
'nothing needs to be done
CASE 1
text$ = LTRIM$(text$) 'delete leading spaces
CASE 2
centretext$ = LTRIM$(RTRIM$(text$))
IF LEN(centretext$) MOD 2 <> 0 THEN centretext$ = centretext$ + " "
lenitm% = LEN(centretext$) 'strip leading & trailing spaces and find length of remaining text
text$ = SPACE$(((winright% - winleft%) - lenitm%) \ 2) + centretext$ 'add proper number of spaces to centre the text
CASE 3
lenitm% = LEN(LTRIM$(RTRIM$(text$))) 'find length of text with leading & trailing spaces deleted
text$ = SPACE$((winright% - winleft%) - (lenitm% + 1)) + LTRIM$(RTRIM$(text$)) 'add proper number of spaces before the text so that text is right justified
END SELECT
Justify$ = text$ 'change justify$ to modified string
END FUNCTION
SUB WindowSub (wintop%, winbot%, winleft%, winright%, winforecolour%, winbackcolour%, wintext$(), winborder%)
REM wintop% & winbot% are the top & bottom rows of the window
REM winleft% & winright% are the left & right coloumns of the window
REM fbg% 'window background colour
REM winforecolour% 'window foreground colour
REM wintext$() is an array containing the text of each line in the window
REM winborder% is a flag which signals the program to add a border(frame) around the window
REM 0 = no border, 1 = border
fbg% = winbackcolour% 'window background colour
ffg% = winforecolour% 'window foreground colour
PCOPY 0, 1 ' copy the current screen to the second page, which is 1
textline% = 1
FOR winline% = wintop% TO winbot% 'put in window filled with
LOCATE winline%, winleft% + 1 'spaces of background colour
COLOR winforecolour%, winbackcolour%
PRINT SPACE$(winright% - winleft%);
LOCATE winline%, winleft% + 1
PRINT wintext$(textline%); 'print text in window
textline% = textline% + 1
NEXT winline%
IF winborder% = 1 THEN CALL Frame(wintop%, winbot%, winleft%, winright%) 'add fram if desired
pause$ = INPUT$(1) 'pause ofter window is complete
PCOPY 1, 0 'copy original screen back to active screen
ERASE wintext$ 'get the array out of memory
END SUB
SUB WindowSub2 (wintop%, winbot%, winleft%, winright%, winforecolour%, winbackcolour%, wintext$(), winborder%)
REM wintop% & winbot% are the top & bottom rows of the window
REM winleft% & winright% are the left & right coloumns of the window
REM fbg% 'window background colour
REM winforecolour% 'window foreground colour
REM wintext$() is an array containing the text of each line in the window
REM winborder% is a flag which signals the program to add a border(frame) around the window
REM 0 = no border, 1 = border
fbg% = winbackcolour% 'window background colour
ffg% = winforecolour% 'window foreground colour
'set up 2 dimensional array to store characters "under" the window
DIM charascii%(wintop% TO winbot%, winleft% TO winright%)
'same as above but to store color attributes
DIM charattrib%(wintop% TO winbot%, winleft% TO winright%)
FOR winline% = wintop% TO winbot%
FOR wincolumn% = winleft% TO winright%
charascii%(winline%, wincolumn%) = SCREEN(winline%, wincolumn%) 'fill character array
FOR winline% = wintop% TO winbot% 'put in window filled with
LOCATE winline%, winleft% + 1 'spaces of background colour
COLOR winforecolour%, winbackcolour%
PRINT SPACE$(winright% - winleft%);
LOCATE winline%, winleft% + 1
PRINT wintext$(textline%); 'print text in window
textline% = textline% + 1
NEXT winline%
IF winborder% = 1 THEN CALL Frame(wintop%, winbot%, winleft%, winright%) 'add fram if desired
pause$ = INPUT$(1) 'pause ofter window is complete
FOR winline% = wintop% TO winbot% 'delete window and replace
FOR wincolumn% = winleft% TO winright% 'original screen
LOCATE winline%, wincolumn%
COLOR charattrib%(winline%, wincolumn%) MOD 16, (charattrib%(winline%, wincolumn%) AND &H70) \ 16 'parse stored colour attributes to foreground and background